package com.xbj.cloud.controller;

import com.xbj.cloud.commons.resp.ResultData;
import com.xbj.cloud.vo.OrderVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author: 观雾
 * @create: 2024-08-08
 * @description:
 **/
@RestController
@Tag(name = "订单微服务模块")
public class OrderController {
    //public static final String Pay8001Server_URL = "http://localhost:8001";
    public static final String Pay8001Server_URL = "http://pay8001";

    @Resource
    private RestTemplate restTemplate;

    @PostMapping(value = "/order80/pay/add2")
    @Operation(summary = "新增",description = "新增支付流水方法,json串做参数")
    public ResultData addPayInfo(OrderVo orderVo){
        return restTemplate.postForObject(Pay8001Server_URL+"/pay/add2",orderVo,ResultData.class);

    }

    @GetMapping(value = "/order80/pay/getById/{id}")
    @Operation(summary = "按照ID查流水",description = "查询支付流水方法")
    public ResultData getPayInfo(@PathVariable("id") Integer id){
        return restTemplate.getForObject(Pay8001Server_URL+"/pay/getById/{id}",ResultData.class,id);
    }

}
